home *** CD-ROM | disk | FTP | other *** search
/ NAFTA Information / NAFTA Information CD-ROM.ISO / windows / nafta.mst < prev    next >
Encoding:
Text File  |  1993-10-04  |  12.7 KB  |  476 lines

  1. '**************************************************************************
  2. '*                       MSSetup Toolkit Sample 2
  3. '**************************************************************************
  4.  
  5. '$DEFINE DEBUG  ''Define for script development/debugging
  6.  
  7. '$INCLUDE 'setupapi.inc'
  8. '$INCLUDE 'msdetect.inc'
  9.  
  10. ''Dialog ID's
  11. CONST ASKQUIT      = 200
  12. CONST DESTPATH     = 300
  13. CONST EXITFAILURE  = 400
  14. CONST EXITQUIT     = 600
  15. CONST EXITSUCCESS  = 700
  16. CONST OPTIONS      = 800
  17. CONST APPHELP      = 900
  18. CONST CUSTINST     = 6200
  19. CONST TOOBIG       = 6300
  20. CONST BADPATH      = 6400
  21.  
  22. ''Bitmap ID
  23. CONST LOGO         = 1
  24.  
  25. ''File Types
  26. CONST APPFILES     = 1
  27. CONST OPTFILES1    = 2
  28.  
  29.  
  30. GLOBAL DEST$        ''Default destination directory.
  31. GLOBAL SRC$         ''CD-ROM Directory.
  32. GLOBAL SRCDRIVE$    ''CD-ROM Directory.
  33. GLOBAL RWSRC$       ''CD-ROM Directory.
  34. GLOBAL WINDRIVE$    ''Windows drive letter.
  35. GLOBAL OPT1OPT$     ''Option selection from OptFiles1 option dialog.
  36.  
  37. ''CustInst list symbol names
  38. GLOBAL APPNEEDS$    ''Option list costs per drive
  39. GLOBAL OPT1NEEDS$
  40. GLOBAL EXTRACOSTS$  ''List of extra costs to add per drive
  41. GLOBAL BIGLIST$     ''List of option files cost calc results (boolean)
  42.  
  43. ''Dialog list symbol names
  44. GLOBAL CHECKSTATES$
  45. GLOBAL STATUSTEXT$
  46. GLOBAL DRIVETEXT$
  47.  
  48.  
  49. DECLARE SUB AddOptFilesToCopyList (ftype%)
  50. DECLARE SUB RecalcOptFiles (ftype%)
  51. DECLARE SUB RecalcPath
  52. DECLARE SUB SetDriveStatus
  53. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  54.  
  55.  
  56.  
  57. INIT:
  58.     CUIDLL$ = "mscuistf.dll"            ''custom user interface dll
  59.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  60.  
  61.     SetBitmap CUIDLL$, LOGO
  62.     SetTitle "Washington C.D. Series"
  63.  
  64.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  65.     IF szInf$ = "" THEN
  66.         szInf$ = GetSymbolValue("STF_CWDDIR") + "NAFTA.INF"
  67.     END IF
  68.     ReadInfFile szInf$
  69.  
  70.     SRC$ = GetSymbolValue("STF_SRCDIR")
  71.     SRCDRIVE$ = MID$(SRC$, 1, 1) + ":"
  72.     RWSRC$ = MID$(SRC$, 1, 1) + ":\NAFTA"
  73.     WINDRIVE$ = MID$(GetWindowsDir, 1, 1)
  74.     DEST$ = WINDRIVE$ + ":\WASHCD"
  75.  
  76.     ''CustInst list symbols
  77.     CHECKSTATES$ = "CheckItemsState"
  78.     STATUSTEXT$  = "StatusItemsText"
  79.     DRIVETEXT$   = "DriveStatusText"
  80.     FOR i% = 1 TO 3 STEP 1
  81.         AddListItem CHECKSTATES$, "ON"
  82.     NEXT i%
  83.     FOR i% = 1 TO 3 STEP 1
  84.         AddListItem STATUSTEXT$, ""
  85.     NEXT i%
  86.     FOR i% = 1 TO 7 STEP 1
  87.         AddListItem DRIVETEXT$, ""
  88.     NEXT i%
  89.     ReplaceListItem DRIVETEXT$, 7, DEST$
  90.  
  91.     ''Disk cost list symbols
  92.     APPNEEDS$   = "AppNeeds"
  93.     OPT1NEEDS$  = "Opt1Needs"
  94.     EXTRACOSTS$ = "ExtraCosts"
  95.     BIGLIST$    = "BigList"
  96.     FOR i% = 1 TO 3 STEP 1
  97.         AddListItem BIGLIST$, ""
  98.     NEXT i%
  99.     FOR i% = 1 TO 26 STEP 1
  100.         AddListItem EXTRACOSTS$, "0"
  101.     NEXT i%
  102.  
  103.     ''File Option Variables
  104.     OPT1OPT$ = "1"
  105.  
  106.     RecalcPath
  107.     SetDriveStatus
  108.  
  109. '$IFDEF DEBUG
  110.     i% = SetSizeCheckMode(scmOnIgnore)    '' could use scmOff; def = scmOnFatal
  111. '$ENDIF ''DEBUG
  112.  
  113.  
  114.  
  115. CUSTINST:
  116.     sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$)
  117.  
  118.     IF sz$ = "CONTINUE" THEN
  119.         ''Install only if it will fit.
  120.         FOR i% = 1 TO 3 STEP 1
  121.             IF GetListItem(BIGLIST$, i%) <> "" THEN
  122.                 GOSUB TOOBIG
  123.                 GOTO CUSTINST
  124.             END IF
  125.         NEXT i%
  126.         UIPop 1
  127.         GOTO INSTALL
  128.     ELSEIF sz$ = "PATH" THEN
  129.         GOTO GETPATH
  130.     ELSEIF sz$ = "CHK1" THEN
  131.         RecalcOptFiles APPFILES
  132.         SetDriveStatus
  133.         GOTO CUSTINST
  134.     ELSEIF sz$ = "CHK2" THEN
  135.         RecalcOptFiles OPTFILES1
  136.         SetDriveStatus
  137.         GOTO CUSTINST
  138.     ELSEIF sz$ = "BTN2" THEN
  139.         GOTO OPTFILES1
  140.     ELSEIF sz$ = "REACTIVATE" THEN
  141.         RecalcPath
  142.         SetDriveStatus
  143.         GOTO CUSTINST
  144.     ELSE
  145.         GOSUB ASKQUIT
  146.         GOTO CUSTINST
  147.     END IF
  148.  
  149.  
  150.  
  151. INSTALL:
  152.     IF GetListItem(CHECKSTATES$, OPTFILES1) = "OFF" THEN
  153.       IF GetListItem(CHECKSTATES$, APPFILES) = "OFF" THEN
  154.          GOSUB ASKQUIT
  155.          GOTO CUSTINST
  156.       ENDIF
  157.     ENDIF 
  158.  
  159.     ClearCopyList
  160.     AddOptFilesToCopyList APPFILES
  161.     AddOptFilesToCopyList OPTFILES1
  162.     CreateDir DEST$, cmoNone
  163.     CopyFilesInCopyList
  164.  
  165.  
  166.  
  167.     IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  168.         CreateProgmanGroup "Washington C.D. Series", "", cmoNone
  169.         ShowProgmanGroup  "Washington C.D. Series", 1, cmoNone
  170.         CreateProgmanItem "Washington C.D. Series", "NAFTA for Windows" , SRC$ + "nafta.exe ..\natext_i", MakePath(DEST$, "nafta.ico"), cmoOverwrite
  171.     END IF
  172.  
  173.     IF GetListItem(CHECKSTATES$, OPTFILES1) = "ON" THEN
  174.         CreateProgmanGroup "Washington C.D. Series", "", cmoNone
  175.         ShowProgmanGroup  "Washington C.D. Series", 1, cmoNone
  176.         CreateProgmanItem "Washington C.D. Series", "NAFTA for Dos" , MakePath(RWSRC$, "rw20.exe -cNAFTA"), MakePath(DEST$, "nafta.ico"), cmoOverwrite
  177.     END IF
  178.  
  179.     CreateProgmanItem "Washington C.D. Series", "Readme", "notepad.exe " + SRCDRIVE$ + "\read.me", "", cmoOverwrite
  180.  
  181.  
  182.  
  183. QUIT:
  184.     ON ERROR GOTO ERRQUIT
  185.  
  186.     IF ERR = 0 THEN
  187.         dlg% = EXITSUCCESS
  188.     ELSEIF ERR = STFQUIT THEN
  189.         dlg% = EXITQUIT
  190.     ELSE
  191.         dlg% = EXITFAILURE
  192.     END IF
  193. QUITL1:
  194.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  195.     IF sz$ = "REACTIVATE" THEN
  196.         GOTO QUITL1
  197.     END IF
  198.     UIPop 1
  199.  
  200.     END
  201.  
  202. ERRQUIT:
  203.     i% = DoMsgBox("Setup sources were corrupted, call 555-1212!", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  204.     END
  205.  
  206.  
  207.  
  208. GETPATH:
  209.     SetSymbolValue "EditTextIn", DEST$
  210.     SetSymbolValue "EditFocus", "END"
  211. GETPATHL1:
  212.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$)
  213.  
  214.     IF sz$ = "CONTINUE" THEN
  215.         olddest$ = DEST$
  216.         DEST$ = GetSymbolValue("EditTextOut")
  217.  
  218.         ''Validate new path.
  219.         IF IsDirWritable(DEST$) = 0 THEN
  220.             GOSUB BADPATH
  221.             GOTO GETPATHL1
  222.         END IF
  223.         UIPop 1
  224.  
  225.         ''Truncate display if too long.
  226.         IF LEN(DEST$) > 23 THEN
  227.             ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..."
  228.         ELSE
  229.             ReplaceListItem DRIVETEXT$, 7, DEST$
  230.         END IF
  231.  
  232.         ''Recalc if path changed.
  233.         IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN
  234.             RecalcPath
  235.             SetDriveStatus
  236.         END IF
  237.  
  238.         olddest$ = ""
  239.         GOTO CUSTINST
  240.     ELSEIF sz$ = "REACTIVATE" THEN
  241.         RecalcPath
  242.         SetDriveStatus
  243.         GOTO GETPATHL1
  244.     ELSEIF sz$ = "EXIT" THEN
  245.         GOSUB ASKQUIT
  246.         GOTO GETPATHL1
  247.     ELSE
  248.         UIPop 1
  249.         GOTO CUSTINST
  250.     END IF
  251.  
  252.  
  253.  
  254. OPTFILES1:
  255.     SetSymbolValue "RadioDefault", OPT1OPT$
  256. OPT1L1:
  257.     sz$ = UIStartDlg(CUIDLL$, OPTIONS, "FRadioDlgProc", APPHELP, HELPPROC$)
  258.     newopt$ = GetSymbolValue("ButtonChecked")
  259.  
  260.     IF sz$ = "CONTINUE" THEN
  261.         UIPop 1
  262.         IF newopt$ <> OPT1OPT$ THEN
  263.             OPT1OPT$ = newopt$
  264.             RecalcOptFiles OPTFILES1
  265.             SetDriveStatus
  266.         END IF
  267.         newopt$ = ""
  268.         GOTO CUSTINST
  269.     ELSEIF sz$ = "REACTIVATE" THEN
  270.         RecalcPath
  271.         SetDriveStatus
  272.         GOTO OPT1L1
  273.     ELSEIF sz$ = "EXIT" THEN
  274.         GOSUB ASKQUIT
  275.         GOTO OPT1L1
  276.     ELSE
  277.         UIPop 1
  278.         newopt$ = ""
  279.         GOTO CUSTINST
  280.     END IF
  281.  
  282.  
  283. TOOBIG:
  284.     sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
  285.     IF sz$ = "REACTIVATE" THEN
  286.         RecalcPath
  287.         SetDriveStatus
  288.         GOTO TOOBIG
  289.     END IF
  290.     UIPop 1
  291.     RETURN
  292.  
  293.  
  294.  
  295. BADPATH:
  296.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  297.     IF sz$ = "REACTIVATE" THEN
  298.         RecalcPath
  299.         SetDriveStatus
  300.         GOTO BADPATH
  301.     END IF
  302.     UIPop 1
  303.     RETURN
  304.  
  305.  
  306.  
  307. ASKQUIT:
  308.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  309.  
  310.     IF sz$ = "EXIT" THEN
  311.         UIPopAll
  312.         ERROR STFQUIT
  313.     ELSEIF sz$ = "REACTIVATE" THEN
  314.         GOTO ASKQUIT
  315.     ELSE
  316.         UIPop 1
  317.     END IF
  318.     RETURN
  319.  
  320.  
  321.  
  322. '**
  323. '** Purpose:
  324. '**     Adds the specified option files to the copy list.
  325. '** Arguments:
  326. '**     ftype%  - type of files to add, one of the following:
  327. '**             APPFILES, OPTFILES1
  328. '** Returns:
  329. '**     none.
  330. '*************************************************************************
  331. SUB AddOptFilesToCopyList (ftype%) STATIC
  332.  
  333.     IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN
  334.         SrcDir$ = GetSymbolValue("STF_SRCDIR")
  335.         IF ftype% = APPFILES THEN
  336.             AddSectionFilesToCopyList "AppFiles", SrcDir$, DEST$
  337.         ELSEIF ftype% = OPTFILES1 THEN
  338.             AddSectionKeyFileToCopyList "OptFiles1", OPT1OPT$, SrcDir$, DEST$
  339.         END IF
  340.         SrcDir$ = ""
  341.     END IF
  342. END SUB
  343.  
  344.  
  345. '**
  346. '** Purpose:
  347. '**     Recalculates disk space for the given option files and sets
  348. '**     the status info symbol "StatusItemsText".
  349. '** Arguments:
  350. '**     ftype% - type of files to add, one of the following:
  351. '**             APPFILES, OPTFILES1
  352. '** Returns:
  353. '**     none.
  354. '*************************************************************************
  355. SUB RecalcOptFiles (ftype%) STATIC
  356.     CursorSave% = ShowWaitCursor()
  357.     ClearCopyList
  358.     AddOptFilesToCopyList ftype%
  359.  
  360.     fExtra% = 0
  361.     IF ftype% = APPFILES THEN
  362.         ListSym$ = APPNEEDS$
  363.         IF GetListItem(CHECKSTATES$, APPFILES) = "ON" THEN
  364.             ''Add extra cost to Windows drive for ini/progman, etc.
  365.             ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  366.             ReplaceListItem EXTRACOSTS$, ndrive%, "10240"
  367.             fExtra% = 1
  368.         END IF
  369.     ELSEIF ftype% = OPTFILES1 THEN
  370.         ListSym$ = OPT1NEEDS$
  371.     END IF
  372.  
  373.     StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "")
  374.  
  375.     cost& = 0
  376.     FOR i% = 1 TO 26 STEP 1
  377.         cost&  = cost& + VAL(GetListItem(ListSym$, i%))
  378.     NEXT i%
  379.     ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K"
  380.  
  381.     IF StillNeed& > 0 THEN
  382.         ReplaceListItem BIGLIST$, ftype%, "YES"
  383.     ELSE
  384.         ReplaceListItem BIGLIST$, ftype%, ""
  385.     END IF
  386.  
  387.     IF fExtra% THEN
  388.         ReplaceListItem EXTRACOSTS$, ndrive%, "0"
  389.     END IF
  390.     RestoreCursor CursorSave%
  391.     ListSym$ = ""
  392. END SUB
  393.  
  394.  
  395. '**
  396. '** Purpose:
  397. '**     Recalculates disk space and sets option status info according
  398. '**     to the current destination path.
  399. '** Arguments:
  400. '**     none.
  401. '** Returns:
  402. '**     none.
  403. '*************************************************************************
  404. SUB RecalcPath STATIC
  405.  
  406.     CursorSave% = ShowWaitCursor()
  407.  
  408.     RecalcOptFiles APPFILES
  409.     RecalcOptFiles OPTFILES1
  410.  
  411.     RestoreCursor CursorSave%
  412. END SUB
  413.  
  414.  
  415. '**
  416. '** Purpose:
  417. '**     Sets drive status info according to latest disk space calcs.
  418. '** Arguments:
  419. '**     none.
  420. '** Returns:
  421. '**     none.
  422. '*************************************************************************
  423. SUB SetDriveStatus STATIC
  424.  
  425.     drive$ = MID$(DEST$, 1, 1)
  426.     ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1
  427.     cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%)) 
  428.     free& = GetFreeSpaceForDrive(drive$)
  429.     ReplaceListItem DRIVETEXT$, 1, drive$ + ":"
  430.     ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K"
  431.     ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"
  432.  
  433.     IF drive$ = WINDRIVE$ THEN
  434.         ReplaceListItem DRIVETEXT$, 4, ""
  435.         ReplaceListItem DRIVETEXT$, 5, ""
  436.         ReplaceListItem DRIVETEXT$, 6, ""
  437.     ELSE
  438.         ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1
  439.         cost& = VAL(GetListItem(APPNEEDS$, ndrive%)) + VAL(GetListItem(OPT1NEEDS$, ndrive%))
  440.         IF cost& = 0 THEN
  441.             ReplaceListItem DRIVETEXT$, 4, ""
  442.             ReplaceListItem DRIVETEXT$, 5, ""
  443.             ReplaceListItem DRIVETEXT$, 6, ""
  444.         ELSE
  445.             free& = GetFreeSpaceForDrive(WINDRIVE$)
  446.             ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":"
  447.             ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K"
  448.             ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K"
  449.         END IF
  450.     END IF
  451. END SUB
  452.  
  453.  
  454. '**
  455. '** Purpose:
  456. '**     Appends a file name to the end of a directory path,
  457. '**     inserting a backslash character as needed.
  458. '** Arguments:
  459. '**     szDir$  - full directory path (with optional ending "\")
  460. '**     szFile$ - filename to append to directory
  461. '** Returns:
  462. '**     Resulting fully qualified path name.
  463. '*************************************************************************
  464. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  465.     IF szDir$ = "" THEN
  466.         MakePath = szFile$
  467.     ELSEIF szFile$ = "" THEN
  468.         MakePath = szDir$
  469.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  470.         MakePath = szDir$ + szFile$
  471.     ELSE
  472.         MakePath = szDir$ + "\" + szFile$
  473.     END IF
  474. END FUNCTION
  475.  
  476.